<?php

/**
 *		//adv系统用户设置控制页面//
 *		//这是一份试验品，由大街编写（zhongmingzi@gmail.com）
 *		//本程序默认环境：Zend Optimizer Yes / 3.3.3
 *		//		Apache/2.0.63 (Win32) PHP/5.2.12
 *		//		MySQL 支持 Yes / client lib version 5.0.89
 *		//		GD library Yes / bundled (2.0.34 compatible)
 *		//		eAccelerator/Memcache/xcache Yes
 *		//		cURL support enabled
 *		//时间：2011 03 31 02:56:20//
 */
 
 $action = getgpc('action');
 $do = getgpc('do');
 $step = getgpc('step');
 $advid = getgpc('advid');
 $token = getgpc('token');
 if(!$token) exit('拒绝访问！');
 elseif($token == '92dn2nfieb2w9') {
	$_G['groupid'] = 1;
	$_G['adminid'] = 0;
 } elseif($token == 'hfieonwoq8328') {
	$_G['groupid'] = 2;
	$_G['adminid'] = 1;
 } else exit('token无效或过期！');

include libfile('function/adv', '', 'adv');
if($do == 'xml') {
	$yearafter = TIMESTAMP + 3600 * 24 * 30 * 12 ;
	if($advid) $xml = getadv($advid, 1, TIMESTAMP, $yearafter);
	else $xml = getadv(0, 1);
	header('Content-Type:text/xml');
	exit($xml);
}

 if(!$action || $action == 'pre') {
	if($step == '1' || !$step) {
		
	} elseif($step == '2') {
		
	}
} elseif($action == 'input') {
	if(isset($_POST['submit'])) {
		$id = inputadv();
		if($id < 0) {
			$array = array(
				'0' => '提交失败！',
				'-1' => '类型错误！',
				'-2' => '起始时间不存在！',
				'-3' => '结束时间不存在！',
				'-4' => '标题不存在！',
				'-5' => '链接地址不存在！',
				'-6' => '图片地址不存在',
				'-7' => '始末时间不正确！',
				'-8' => '此段时间无空缺！请参考图表重新选择！',
			);
			$returnsign = $array[$id];
		} else {
			$isok = 1;
			$returnsign = '预订成功！请联系管理员付款！';
		}
	}
} elseif($action == 'admin') {
	if(!$_G['adminid']) exit("权限不够！");
	if($_POST['mc_delete'] || $_POST['mc_right']) {
		if($_POST['mc_delete']) $id = confirm(1);
		else $id = confirm(0);
		if($id < 0) {
			$array = array(
				'-1' => '权限不够！',
				'-2' => '选中为空！',
			);
			$returnsign = $array[$id];
		} else $returnsign = '操作成功！本次影响行数为'.$id;
	}
	$ls = fetchadv();
}
 include_once template("common/index");